<template>
  <div>
    <van-search v-model="value" placeholder="请输入搜索关键词" @click="$router.push('/app/search')" />
    <van-swipe :autoplay="3000">
  <van-swipe-item v-for="(image, index) in images" :key="index">
    <img v-lazy="image" />
  </van-swipe-item>
</van-swipe>
    <glist :user_list="user_list" @add="addCart" />
  </div>
</template>
<script>
import glist from './glist'
export default {
  components:{
glist,
  },
  data() {
    return {
      value: "",
      user_list: [],
      images: [
        'https://img01.yzcdn.cn/vant/apple-1.jpg',
        'https://img01.yzcdn.cn/vant/apple-2.jpg',
      ],
    };
  },
  created(){
this.List()
  },
  methods: {
      List(){
          this.$axios.post('https://api.it120.cc/small4/shop/goods/list').then(res=>{
              console.log(res);
              this.user_list = res.data
          })
      },
      addCart(good){
        this.$set(good,'checked',false)
          this.$set(good,'num',1)
          this.$store.commit('addCart',good)
      }
  },
};
</script>
<style lang="scss" scoped>
img{
    width: 100%;

}
</style>